/**
 * 通用的返回JSON数据的结构s
 * Created by zhanggj
 * At 2013-4-12
 */
package com.chouxiaozi.miniprogram.bean;

import java.io.Serializable;

public class JsonResult<T> implements Serializable {
	private static final long serialVersionUID = -7774388366961482552L;

	private int retcode; // 状态码
	private String retmsg; // 消息
	private T retdata; // 返回的数据
	
	public JsonResult() {
		
	}
	
	public JsonResult(int retcode, String retmsg, T retdata) {
		this.retcode = retcode;
		this.retmsg = retmsg;
		this.retdata = retdata;
	}

	public int getRetcode() {
		return retcode;
	}

	public void setRetcode(int retcode) {
		this.retcode = retcode;
	}

	public String getRetmsg() {
		return retmsg;
	}

	public void setRetmsg(String retmsg) {
		this.retmsg = retmsg;
	}

	public Object getRetdata() {
		return retdata;
	}

	public void setRetdata(T retdata) {
		this.retdata = retdata;
	}
	
	public static JsonResult success(Object obj) {
		JsonResult ret = new JsonResult();
		ret.setRetcode(0);
		ret.setRetmsg("");
		ret.setRetdata(obj);
		return ret;
	}
	
	public static JsonResult failure(String msg, Object obj) {
		JsonResult ret = new JsonResult();
		ret.setRetcode(-1);
		ret.setRetmsg(msg);
		ret.setRetdata(obj);
		return ret;
	}

}
